﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _50集合的练习
{
    class Program
    {
        static void Main(string[] args)
        {
            //练习一：创建一个集合，里面添加一些数字，求平均值与和
            //ArrayList list = new ArrayList();
            //list.AddRange(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 });
            //int sum = 0;
            //int num = 0;
            //int coun = 0;
            //int e = 0;
            //for (int i = 0; i < list.Count; i++)
            //{
            //    sum += (int)list[i];
            //    num = sum / (int)list[i];
            //    if ((int)list[i] > coun)
            //    {
            //        coun = (int)list[i];
            //    }
            //    else
            //    {
            //        coun = (int)list[i];
            //    }
            //}
            //Console.WriteLine("总和是{0},平均值是{1},最大值是{2},最小值是{3}", sum, num,coun,e);
            //Console.ReadKey();


            //练习二
            ArrayList list = new ArrayList();
            Random r = new Random();
            for (int i = 0; i < 10; i++)
            {
                int Number = r.Next(0, 10);
                if (!list.Contains(Number))
                {
                    list.Add(Number);
                }
                else
                {
                    i--;
                }
            }
            for (int i = 0; i < list.Count; i++)
            {
                Console.WriteLine(list[i]);
            }
            Console.ReadKey();
        }
    }
}
